#pragma once
#include <stdint.h>
#include "mqtt_client.h"
#include "cJSON.h"

typedef const char* (*tb_rpc_callback_t)(cJSON* params);

typedef struct {
    const char* method;
    tb_rpc_callback_t handler;
} tb_rpc_method_t;

void tb_rpc_init(esp_mqtt_client_handle_t client);
void tb_rpc_subscribe(const char* method, tb_rpc_callback_t handler);
void tb_handle_rpc(const char* topic, const uint8_t* payload, int length);
